package com.umeox.watch.moto.camera.utils

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView

/**
 * Created by Rambo 2024/4/9/0009
 * Describe:
 */
class HorizontalItemDecoration(val space: Int) :
    RecyclerView.ItemDecoration() {

    override fun getItemOffsets(
        outRect: Rect,
        view: View,
        parent: RecyclerView,
        state: RecyclerView.State
    ) {
        outRect.right = space
        parent.adapter?.let {
            //最后一个控件不设置边距
            if (parent.getChildAdapterPosition(view) == it.itemCount - 1)
                outRect.right = 0
        }
    }
}
